<?php
include "includes/ui.php";
include_once "controls/register_detail_db.php";
echo headerHTML("service","ลงทะเบียนใช้บริการ");

$m_db = new M_Register_Detail();
 
$Year=2557;
$Term=1;
?> 
 <div id="popup" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

 <form class="list-widget" id="pagination-todo" style='margin-bottom:0px;'>

        <div class="modal-body" style="overflow-y:auto;padding:1px;">
		 <div class="top-bar">
            <h3><i class="icon-calendar"></i> คอร์สเรียนพิเศษ</h3>
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style='color:#fff !important;margin-top:5px;' >×</button>
         </div>
		 <div class="well no-padding" style='margin-bottom:0px;' >
		<?php
			$result=$m_db->load_course($Year,$Term,0 );
			if ($m_db->getRowCount()>0){
			$check="";
			 while($row = $result->FetchRow()){
			  $check= $row['isSelect']==0?"":"checked";
		?>
			<div class="item" style="display: block;padding-bottom:10px;">
				<label class="checkbox">
					<div class="row-fluid">
					<input type="checkbox" name='course' id='c<?php echo $row['id'];?>' value='<?php echo $row['id'];?>'>  <?php  echo $row['subject_name']. ' '. $row['detail'];?> <span name='tcourse' id='t<?php echo $row['id'];?>' style='color:red'></span>
					<small class="pull-right" style='color:orange;'><?php echo number_format($row['cost'],0,'',',').'/'.$row['cost_type'];?></small>
					</div>
					<?php 
						$cbo='';
						$html1="";
						$html2="";
						if ($row['course_type']==3){
							$teacher_result = $m_db->load_teacher_list($row['id']);
							$cbo=" <select class='no-margin span8' name='cboTeacher' id='cboTeacher_".$row['id']."'  style='width:250px !important;'>";
									
							while ($t_row = $teacher_result ->FetchRow()){
								$cbo .= "<option value=".$t_row['id'].">".$t_row['emp_name']."</option>";
							}
							$cbo.="</select>";
							$html2 = "<tr><td colspan='3'>เลือกครูสอน : &nbsp; ".$cbo."</td></tr>";
						}
						$result2=$m_db->load_course_detail($row['id']);
						
						$class_list="";
						$date_list="";
						while($row2 = $result2->FetchRow()){
							$class_list = $m_db->getClasslist($row2['for_class']);
							$date_list = $m_db->getDate($row2['study_date']);
							$html1.="<tr><td style='text-align:left;'><span style='display:block;' class='help-inline'>".$class_list ."</span></td>";
							$html1.="<td style='text-align:center;'><span style='display:block;' class='help-inline'>".$date_list ."</span></td>";
							$html1.="<td style='text-align:right;'><span style='display:block;' class='help-inline'>".$row2['study_time'].'-'.$row2['study_time_end'].' น.'."</span></td></tr>";
						}
					?>
					<div class="row-fluid" style='margin-top:10px;'>
						<table class='table' width="100%">
							<?php echo $html1 . $html2;?>
						</table>
						
					</div>
				</label>
			</div>
		 <?php 
			}
			}
		 ?>
		</div>		 
        </div>

        <div class="modal-footer">

 			   <button type='button' class="btn btn-primary" id="btnRegistCourse">ลงทะเบียน</button>
				<button class="btn" data-dismiss="modal" aria-hidden="true">ยกเลิก</button>
              
        </div>
  </form>

</div> 

<div id="popup_car" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<form class="list-widget" id="pagination-todo" style='margin-bottom:0px;'>
	  <div class="modal-body" style="overflow-y:auto;padding:1px;">
	<div class="top-bar">
          <h3><i class="icon-truck"></i> รถโรงเรียน</h3>
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true" style='color:#fff !important;margin-top:5px;' >×</button>
     </div>
		 <div class="well no-padding" style='margin-bottom:0px;' >
 
       
		<!-- Todo List: Item -->
			<?php	
				$result=$m_db->load_bus($Year,$Term,0);
				if ($m_db->getRowCount()>0){
					$check="";
					$lock ="";
					while($row_bus=$result->FetchRow()){
						$check= $row_bus['isSelect']==0?"":"checked";
						if ( $row_bus['cnt']!=0)
							$lock=$disable;
							
						$result_bus_detail = $m_db->load_bus_detail($row_bus['id']);
						$html="";
						while($row_bus_detail = $result_bus_detail->FetchRow()){
							$html.="".$row_bus_detail['route']."<br/>";
						}
			?>
			<div class="item" style="display: block;">
				<label class="radio" <?php echo $lock;?>>
					<input type="radio" name='bus' id='bus_<?php echo $row_bus['id'];?>' value='<?php echo $row_bus['id'];?>'>  <?php echo $row_bus['detail'];?>
					<span name='tbus' id='b<?php echo $row['id'];?>' style='color:red'></span>
					<small class="pull-right" style='color:orange;'><?php echo number_format($row_bus['cost'],0,'',',') ."/". $row_bus['cost_type']; ?></small>
					<p style='padding:0px; padding-top:10px padding-left:10px;margin:5px 0 0 0;'><b>เส้นทาง</b> 
					<?php echo $html;?>
					</p>
				</label>
			</div>
			<?php
			}
			}
			
			?>
			 <div class="item" style="display: block;">
			<label class="radio">
				<input type="radio" name='bus' id='bus_0' value='0'  />ไม่ใช้บริการ
				<small class="pull-right" style='color:orange;'> </small>
				<p style='padding:0px; padding-top:10px padding-left:10px;margin:5px 0 0 0;'><b></b> 
				 
				</p>
			</label>
			</div>
			<!-- / Todo List: Item -->
		</div>
	
		  <div class="modal-footer">

 			<button type='button' class="btn btn-primary" id="btnRegistCar">ลงทะเบียน</button>
			<button class="btn" data-dismiss="modal" aria-hidden="true">ยกเลิก</button>
              
        </div>
		</div>
	</form>
	
</div>
<!-- Live Stats -->
<div class="row-fluid">

    <!-- Pie: Box -->
    <div class="span12">

        <!--  : Top Bar -->
        <div class="top-bar">
            <h3><i class="icon-cog"></i> ลงทะเบียนใช้บริการ</h3>
        </div>
        <!-- /  : Top Bar -->

        <!-- Pie: Content -->
        <div class="well no-padding" >
			<div class="span12">
				<div class="row-fluid">
				 <form class="form-horizontal" style='margin-bottom:0px;'>
					<div class='span12'>
					 <div class="control-group" >
								<label class="control-label" style='padding-top:5px;' for="inputName"><i class="icon-double-angle-right"></i> ปีการศึกษา</label>
								<div class="controls">
									<select class="no-margin span8" id='cboYear' style="width:150px !important;">
									 
									</select>
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;margin-left:50px;"> ภาคเรียน</span>
									&nbsp;<select class="no-margin" id='txtTerm'  tabindex="1" style="width:100px !important;">
										</select>
									<!--input type="text" id="txtTerm" maxlength="1" value="1" class="span1 txtamt"-->
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;margin-left:50px;"> ระดับชั้น</span>
									&nbsp;<select class="no-margin span8"  id='cboClass' style="width:150px !important;"></select>
									<select class="no-margin span8"  id='cboRoom' style="width:70px !important;"></select>
								</div>
					 </div>
					 
					  <div class="control-group" >
						<label class="control-label"  for="inputName"><i class="icon-double-angle-right"> </i>รหัสนักเรียน</label>
						<div class="controls">
							<input type="text" id="txtCode" maxlength="10" class="span2" placeholder="561XX">
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">ชื่อ - นามสกุล</span>
							&nbsp;&nbsp;&nbsp;<input type="text" id="txtName" class="span4" placeholder="">
							<button class="btn btn-inverse" type='button' id='btnSearch' style='height:30px;margin-left:50px;margin-top:0px;padding-top:0px;' rel="tooltip" title=""   data-original-title="ค้นหาข้อมูล"><i class="icon-search"></i></button> 
						</div>
					 </div>
				 
					</form>
				</div>
			</div>
			<form class="form-horizontal" id='frmRegist' method="post" action="register_detail.php">
			<input type='hidden' id="m_id" name='m_id' value=''/>
			<input type='hidden' id="m_year" name='m_year' value=''/>
			<input type='hidden' id="m_term" name='m_term' value=''/>
            <table class="data-table" id="resultData" >
                <thead style='border-top:1px solid #c2c2c2;border-bottom:1px solid #c2c2c2;'> 
                    <tr >
                        <th style='color:#333 !important;width:20px !important;'>#</th>
						<th style='color:#333 !important;width:0px !important;'></th>
						<th style='color:#333 !important;width:100px !important;' class='center'>ภาคเรียน</th>
					    <th style='color:#333 !important;width:100px !important;' class='center'>รหัสนักเรียน</th>
						<th style='color:#333 !important;' class='center'>ชื่อ - นามสกุล</th>
						<th style='color:#333 !important;' class='center'>ชื่อ เล่น</th>
						<th style='color:#333 !important;width:150px !important;' class='center'>ระดับชั้น/ห้อง</th>
						<th style='color:#333 !important;width:100px !important;' class='center'>วันที่กรอกข้อมูล</th>
						<th style='color:#333 !important;width:150px !important;' class='center'> คอร์สเรียนพิเศษ</th>
						<th style='color:#333 !important;width:100px !important;' class='center'>รถโรงเรียน</th>
						<!--h style='color:#333 !important;width:60px;' class='center'>แก้ไข</th>
						<th style='color:#333 !important;width:60px;' class='center'>ลบ</th-->
                    </tr>
                </thead>
                <tbody>
                     </tbody>

            </table>
			</form>
        </div>
        <!-- / Pie: Content -->

    </div>
    <!-- / Pie -->

</div>
<!-- / Live Stats -->

<?php
echo footerHTML();
?>

<!-- Javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src='js/jquery.hotkeys.js'></script>
<!--script src='js/fullcalendar.min.js'></script-->
<script src="js/jquery-ui-1.10.2.custom.min.js"></script>
<script src="js/jquery.pajinate.js"></script>
<!--script src="js/jquery.prism.min.js"></script-->
<script src="js/jquery.dataTables.min.js"></script>

<script src="js/jquery.flot.resize.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-wysiwyg.js"></script>
<!--script src="js/bootstrap-typeahead.js"></script-->
<script src="js/jquery.easing.min.js"></script>
<script src="js/jquery.chosen.min.js"></script>
<script src="js/avocado-custom.js"></script>

<script src="js/myScript/js_other_register.js"></script>


</html>